
import {serverAuthCheck} from "./common/auth";
import SysUserService from "./service/sys/SysUserService";
import {useController} from "./common/utils/appUtils";
//采用默认的express  构建服务器中间件创建api
const express = require('express')

const app = express()

//简单的权限校验
app.all('/*', function (req, res, next) {
  serverAuthCheck(req,res,next,SysUserService);
})

//开启session
const session=require("express-session")
app.use(session({
  secret: "keyboard cat",
  resave: false,
  saveUninitialized: true,
  cookie: ('name', 'value',{maxAge:  5*60*1000,secure: false})
}));

//配置可解析json参数
app.use(express.json())
app.use(express.urlencoded({ extended: true }))

//扫描所有controller
useController(app)

module.exports = {
  path:"/",
  handler: app
}
